MODE ?= FILE

.PHONY: all clean help

all:
	@echo "================================="
	@echo " 学生选课系统编译开始 "
	@echo " 产品形态：$(MODE)模式"
	@echo "================================="
	@echo "编译学生信息管理模块..."
	$(MAKE) -C ModuleStudent MODE=$(MODE)
	@echo "编译课程管理模块..."
	$(MAKE) -C ModuleCourse MODE=$(MODE)
	@echo "编译文件IO模块..."
	$(MAKE) -C ModuleFileIO MODE=$(MODE)
	@echo "连接生成可执行文件..."
	@gcc -I./Include -o Release/student_system \
		main.c \
		ModuleStudent/*.o \
		ModuleCourse/*.o \
		ModuleFileIO/*.o \
		-DINPUT_MODE_$(MODE)
	@echo "编译完成！可执行文件：Release/student_system"

clean:
	@echo "清理所有编译文件..."
	@rm -rf Release/*
	@find . -name "*.o" -delete
	@$(MAKE) -C ModuleStudent clean
	@$(MAKE) -C ModuleCourse clean
	@$(MAKE) -C ModuleFileIO clean
	@echo "清理完成!"

help:
	@echo "可用命令："
	@echo " make all MODE=FILE  -编译文件输入版本"
	@echo " make all MODE=CLI   -编译命令行输入版本"
	@echo " make clean          -清理所有编译文件"
	@echo " make help           -显示帮助信息"
